const DataTableModel = require('../db/models/data_table');
//修改

class Server { //修改
  //修改
  async addData (data) {
    //查询
    const result = await DataTableModel.findOne();
    //判断 check
    if (result) { 
      //更新 update  //修改
      return await DataTableModel.update(data, {where: { id: 1 }})
    }else {
      //创建 create
      return await DataTableModel.create(data);
    }
  }

  async getData () {
    return await DataTableModel.findOne();
  }
}
//修改
module.exports = new Server();